package com.demo.controllers;

import com.baomidou.mybatisplus.mapper.Condition;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.demo.entity.User;
import com.demo.mapper.UserDao;
import com.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.Size;
import java.util.LinkedList;
import java.util.List;

/**
 * @Description:
 * @author: fanfan
 * @date: 2018/5/11 16:58
 */


@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/getUser")
    public User getUsers( String userId){

        Wrapper<User> con=new Condition();
        con.eq("user_id",userId);
        return userService.selectOne(con);
    }


    @RequestMapping("/getBUser")
    public Page getBUser(HttpServletRequest request){
        Page page=new Page();
        page.setCurrent(Integer.parseInt(request.getParameter("current")));
        page.setSize(Integer.parseInt(request.getParameter("size")));
        Wrapper<User> con=new Condition();
        con.eq("user_type","B");
        page.setTotal(userService.selectCount(con));
        return userService.selectPage(page,con);
    }

}
